
<div class="division receiver" id="receiver">

    <{if $trading.receiver.addrlist}>
      <ul class='list receiver-sel'>
	  <{foreach from=$trading.receiver.addrlist key=iloop item=addr}>
       <li>
        <input type="radio" name="delivery[addr_id]" value="<{$addr.addr_id}>"<{if $addr.def_addr}> checked="checked"<{/if}>><{$addr.addr_region|region}> <{$addr.addr_label}>
        &nbsp;<a href="javascript:void(0)" class="lnk addredit"><{t}>Edit<{/t}></a>	    
		</li>
        <{/foreach}>
		<li>
        <input type="radio" name="delivery[addr_id]" value="0">Others Receiving Address
		</li>
	  </ul>
        <div id="checkout-recaddr" style='display:none'></div>
     <{else}>
       <div id='checkout-recaddr'>
           <{include file="shop:common/rec_addr.html"}>
        </div>
     <{/if}>

  <div class='receivermore' style='padding:5px;margin-top:4px;'>
     <{t}>Order postscript:<{/t}><{input class="inputstyle" name="delivery[memo]" type="text" value="" style='width:400px'}>
    Specified delivery time:<input type='checkbox' onclick='$(this).getNext("div")[this.checked?"show":"hide"]();'/>
    <div style='display:none;margin-top:4px'>
     <{t}>Delivery Time:<{/t}><select class="inputstyle" name="delivery[day]" onchange="$('specal_day').style.display=(this.value=='specal')?function(){$('specal_day').getFirst().makeCalable(); return '';}():'none'">
            <option selected="selected" value="Any date"><{t}>Any date<{/t}></option>
            <option value="Only work days"><{t}>Only work days<{/t}></option>
            <option value="Only rest day"><{t}>Only rest day<{/t}></option>
            <option value="specal"><{t}>Appointed<{/t}></option>
          </select>&nbsp;
          <span id="specal_day" style="display:none">
             <{input type="text" name="delivery[specal_day]" class="cal inputstyle" value=$dlytime real=true style="width:80px" readonly=true}>
          </span>
        <select class="inputstyle" name="delivery[time]">
            <option value="Any time"><{t}>Any time<{/t}></option>
            <option value="AM"><{t}>AM<{/t}></option>
            <option value="PM"><{t}>PM<{/t}></option>
            <option value="Night"><{t}>Night<{/t}></option>
          </select>
      </div>
  </div>
</div>
 <{if $trading.receiver.addrlist}>
<script>
window.addEvent('domready',function(){

<{if $trading.admindo}>
    var url_area = 'index.php?ctl=order/order&act=getAddr';
<{else}>
    var url_area = '<{link ctl="cart" act="getAddr"}>';
<{/if}>


   
    var addlistRadios=$$('input[name^=delivery[addr_id]','receiver');
    
    if(addlistRadios.length){
 
        addlistRadios.addEvent('click', function(e,edit){      
                this.set('checked',true);             
                var _value=this.value;
                
                if(_value!='0'){
                   $('checkout-recaddr').hide();
                }
                
                if(edit){
                   $('checkout-recaddr').show();
                }
            
                
                new Request.HTML({
                    url:url_area,
                    update:'checkout-recaddr',
                    onRequest:function(){
                      $('checkout-recaddr').set('html','<div class="fontcolorGreen">loading...</div>');
                    },
                    onComplete:function(){

                     if(_value=='0'){
                         
                      $('shipping').set('html','<div class="valierror clearfix"><{t}>Please complete the receipt information.<{/t}></div>');

                         return;                      
                     }
                  
                     /*$E('#checkout-recaddr .recsave td')
                     .adopt(new Element('span',{'class':'ColColorGray'})
                     .set('html','&nbsp;&nbsp;(勾选保存将覆盖您之前保存的收货人信息)'));*/
                  
                      
                      if(lastsel=$ES('#checkout-select-area select').getLast()){
                          
                          if(!lastsel.getValue()||lastsel.getValue()=='_NULL_'){
                               $('shipping').set('html','<div class="valierror clearfix"><{t}>Please complete the receipt information.<{/t}></div>');
                               MessageBox.error('Please re-select: Receiving Area.');
                               $('checkout-recaddr').show();
                          
                          }
                          
                      }
                    
                    }}).get({'addr_id':_value});
            });
            
       addlistRadios[0].fireEvent('click');
       addlistRadios.getLast().addEvent('click',$('checkout-recaddr').show.bind($('checkout-recaddr')));
   }

  $$('.addredit','receiver').addEvent('click', function(e){
            e.stop();
            /*var ipt =this;
            var addrRow = ipt.getPrevious('label');
            var addrObj = addrRow.getElement('input[name^=delivery[addr_id]');*/
            this.getPrevious('input[name^=delivery[addr_id]').fireEvent('click',[e,true]);
        });

        
        
});
</script>
<{/if}>